﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Game.model;

namespace Game.ai
{
   public class Guard:Fighter
{
	/**
	 * Constructor for Guard.
	 * @param actor NpcInstance
	 */
	public Guard(NpcInstance actor):base(actor)
	{
		//super(actor);
	}
	
	/**
	 * Method canAttackCharacter.
	 * @param target Creature
	 * @return boolean
	 */
	
	public override bool canAttackCharacter(Creature target)
	{
		NpcInstance actor = getActor();
		if (getIntention() == CtrlIntention.AI_INTENTION_ATTACK)
		{
			AggroList.AggroInfo ai = actor.getAggroList().get(target);
			return (ai != null) && (ai.hate > 0);
		}
		return target.isMonster() || target.isPlayable();
	}
	
	/**
	 * Method checkAggression.
	 * @param target Creature
	 * @return boolean
	 */
	
	public override bool checkAggression(Creature target)
	{
		NpcInstance actor = getActor();
		if ((getIntention() != CtrlIntention.AI_INTENTION_ACTIVE) || !isGlobalAggro())
		{
			return false;
		}
		if (target.isPlayable())
		{
			if ((target.getKarma() >= 0) || (actor.getParameter("evilGuard", false) && (target.getPvpFlag() > 0)))
			{
				return false;
			}
		}
		if (target.isNpc())
		{
			if (((NpcInstance) target).isInFaction(actor))
			{
				return false;
			}
			if (target.isMonster())
			{
				if (!((MonsterInstance) target).isAggressive())
				{
					return false;
				}
			}
		}
		return base.checkAggression(target);
	}
	
	/**
	 * Method getMaxAttackTimeout.
	 * @return int
	 */
	
	public override int getMaxAttackTimeout()
	{
		return 0;
	}
	
	/**
	 * Method randomWalk.
	 * @return boolean
	 */
	
	protected override bool randomWalk()
	{
		return false;
	}
}

}
